/**
* @author zqp
* @version2017年12月21日 
* @description 
*/
package com.zqp.security.core.validator.code.sms;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.Random;

import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.context.request.ServletWebRequest;

import com.zqp.security.core.properties.SecurityProperties;
import com.zqp.security.core.validator.code.ValidateCode;
import com.zqp.security.core.validator.code.ValidateCodeGenerator;

/**
* @author zqp
* @version2017年12月21日 
* @description 
*/
@Component("smsCodeGenerator")
public class SmsCodeGenerator implements ValidateCodeGenerator {

	/***
	 * 系统配置
	 */
	@Autowired
	private SecurityProperties securityProperties;
	@Override
	public ValidateCode createCode(ServletWebRequest request) {
		String code = RandomStringUtils.randomNumeric(securityProperties.getCode().getSms().getLength());
		return new ValidateCode(code, securityProperties.getCode().getSms().getExpireIn()); 
	}
	public SecurityProperties getSecurityProperties() {
		return securityProperties;
	}
	public void setSecurityProperties(SecurityProperties securityProperties) {
		this.securityProperties = securityProperties;
	}

}
